package cn.edu.neusoft.wuguangsheng.flowerimpression.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.squareup.picasso.Picasso;

import java.util.List;

import cn.edu.neusoft.wuguangsheng.flowerimpression.activity.PhotoInfoActivity;
import cn.edu.neusoft.wuguangsheng.flowerimpression.bean.BaiKePhotoBean;
import cn.edu.neusoft.wuguangsheng.flowerimpression.service.Service;

public class BaiKeTuKuAdapter extends BaseAdapter<BaiKePhotoBean> {

    public BaiKeTuKuAdapter(Context context, List<BaiKePhotoBean> items, int layoutResourse) {
        super(context, items, layoutResourse);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView= LayoutInflater.from(context).inflate(layoutResourse,parent,false);
        MeiTuViewHolder viewHolder = new MeiTuViewHolder(itemView);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        MeiTuViewHolder meiTuViewHolder=(MeiTuViewHolder) holder;
        BaiKePhotoBean baiKePhotoBean=items.get(position);

        final String img = Service.BASE_URL+"flower_impression/public/uploads/"+baiKePhotoBean.getEncphoto_imgname();
        // Toast.makeText(context,img,Toast.LENGTH_SHORT).show();
        Picasso.with(context).load(img).into(meiTuViewHolder.meituitem);
        meiTuViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //Toast.makeText(context,img,Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(context, PhotoInfoActivity.class);
                intent.putExtra("imgpath",img);
                context.startActivity(intent);
            }
        });
    }
}
